//
//  PlayViewController.m
//  OwnerNews
//
//  Created by lanou3g on 15/9/4.
//  Copyright (c) 2015年 Drawzyn. All rights reserved.
//

#import "PlayViewController.h"
#import "AvdiovisualModel.h"
#import "AudiovisualManager.h"


@interface PlayViewController ()<MPMediaPickerControllerDelegate>

@property (nonatomic,strong)UIButton *button;

@property (nonatomic,strong)UILabel *Detiallabel;


@end

@implementation PlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = YES;
    AvdiovisualModel *AVM = [AudiovisualManager defaultManager].AvManAgerData[_MyIndexPath.row];
    //初始化一个视频播放器
    _movieC = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:AVM.mp4_url]];
    _movieC.view.frame = self.view.frame;
    [_movieC setFullscreen:YES animated:YES];
    //把播放器添加到当前视图上
    [self.view addSubview:_movieC.view];
    //播放
    [_movieC prepareToPlay];
    [_movieC play];
    
    _button = [[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width - 50, 30, 40, 30)];
    [_button setTitle:@"返回" forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(ComeBackAction) forControlEvents:UIControlEventTouchUpInside];
    [_movieC.view addSubview:_button];
    
    _Detiallabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 60, self.view.frame.size.width - 10, 60)];
//    _Detiallabel.backgroundColor = [UIColor grayColor];
    _Detiallabel.layer.masksToBounds = YES;
    _Detiallabel.layer.cornerRadius = 5;
    _Detiallabel.numberOfLines = 0;
    _Detiallabel.textColor = [UIColor redColor];
    _Detiallabel.text = [NSString stringWithFormat:@"%@ : %@",AVM.title,AVM.AVdescription];
    [_movieC.view addSubview:_Detiallabel];
    
}

- (void)ComeBackAction {
    [self dismissViewControllerAnimated:YES completion:^{
        [_movieC stop];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
